Skip to content

Conversation

@notfoundzzz
Copy link
Contributor

如何测试

  1. 删除 %APPDATA%\moganlab\system\settings.scm 后启动
    预期:仅显示欢迎文档,不出现额外“无标题”
  2. 从文件管理器用软件打开 .tmu 文件
    预期:仅显示目标文件,不出现额外“无标题”
  3. 无参数启动(非首次)
    预期:显示一个空白文档

2026/02/10

What

  • 启动时复用空白缓冲区加载欢迎文档,避免多出“无标题”缓冲区
  • 通过“打开方式”启动文件时,复用空白缓冲区加载目标文档
  • 若有启动文件参数,则不再加载欢迎文档

Why

  • 启动阶段必须先有可用视图,避免崩溃
  • 用户打开欢迎文档或直接打开文件时,不应额外出现“无标题”文档

@notfoundzzz notfoundzzz marked this pull request as draft February 10, 2026 02:17
@notfoundzzz notfoundzzz marked this pull request as ready for review February 10, 2026 02:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 旨在优化启动阶段的缓冲区/视图复用逻辑:在首次启动加载欢迎文档、或通过“打开方式/命令行”启动打开文件时,复用启动时的空白缓冲区,避免额外出现一个“无标题”缓冲区;同时在存在启动文件参数时不再加载欢迎文档。

Changes:

  • 启动阶段加载欢迎文档改为调用 (mogan-welcome-startup),并在无启动文件参数时才加载欢迎文档
  • 新增 Scheme API load-buffer-into-current,用于在启动阶段将目标文档加载进当前空白 scratch buffer
  • 重构欢迎文档路径逻辑(抽出 mogan-welcome-path),并补充开发记录文档(新增 222_42、删除 222_34)

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/System/Boot/init_texmacs.cpp 启动阶段根据是否有外部启动文件决定是否加载欢迎文档;首次文件用新 Scheme API 复用当前缓冲区加载
TeXmacs/progs/texmacs/texmacs/tm-files.scm 新增 load-buffer-into-current,并调整 load-buffer-open 的逻辑(移除旧的 scratch buffer 关闭逻辑)
TeXmacs/progs/doc/help-funcs.scm 抽出 mogan-welcome-path,新增 mogan-welcome-startup 用于启动阶段复用缓冲区加载欢迎文档
devel/222_42.md 新增本次改动的开发记录与测试步骤
devel/222_34.md 删除旧开发记录文档

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

((buffer-exists? name)
;; 复用当前空白缓冲区前,优先切换到已打开的目标缓冲区。
(load-buffer-open name opts)
(buffer-close cur))
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

load-buffer-into-current closes cur unconditionally in the (buffer-exists? name) branch. When options include :background, load-buffer-open is a no-op (see its (in? :background opts) branch), so this will close the current scratch buffer even though no buffer switch occurred. Consider either rejecting/ignoring :background (and :new-window) for this helper, or only calling buffer-close cur when you actually switched away from cur (i.e., not in background mode).

Suggested change
(buffer-close cur))
;; 仅在非后台、非新窗口模式下,才关闭当前缓冲区。
(if (and (nin? :background opts)
(nin? :new-window opts))
(buffer-close cur)))

Copilot uses AI. Check for mistakes.
Comment on lines +631 to +634
(let* ((doc (tree-import target (url-format target))))
(buffer-rename cur name)
(buffer-set name doc)
(load-buffer-open name opts))))
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

load-buffer-into-current uses tree-import and then renames/overwrites the current scratch buffer without checking for import failure. Elsewhere (e.g., revert-buffer-revert) the code checks (== t (tm->tree "error")) to surface an error message. Consider adding a similar check before buffer-rename/buffer-set, so a corrupted/unsupported file doesn’t silently replace the current buffer with an error tree.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant